// This example shows how to get a value of a single OPC XML-DA property. // // Note that some properties may not have a useful value initially (e.g. until the item is activated in a group), which also the // case with Timestamp property as implemented by the demo server. This behavior is server-dependent, and normal. You can run // IEasyDAClient.ReadItemValue.Main.vbs shortly before this example, in order to obtain better property values. Your code may // also subscribe to the item in order to assure that it remains active. // // Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html . // OPC client and subscriber examples in C# on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-CSharp . // Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own // a commercial license in order to use Online Forums, and we reply to every post. using System; using OpcLabs.EasyOpc.DataAccess; using OpcLabs.EasyOpc.OperationModel; namespace DocExamples.DataAccess.Xml { partial class GetPropertyValue { public static void Main1Xml() { // Instantiate the client object. var client = new EasyDAClient(); object value; try { value = client.GetPropertyValue("http://opcxml.demo-this.com/XmlDaSampleServer/Service.asmx", "Dynamic/Analog Types/Int", DAPropertyDescriptor.Timestamp); } catch (OpcException opcException) { Console.WriteLine("*** Failure: {0}", opcException.GetBaseException().Message); return; } Console.WriteLine(value); } } }
' This example shows how to get a value of a single OPC XML-DA property. ' ' Note that some properties may not have a useful value initially (e.g. until the item is activated in a group), which also the ' case with Timestamp property as implemented by the demo server. This behavior is server-dependent, and normal. You can run ' IEasyDAClient.ReadItemValue.Main.vbs shortly before this example, in order to obtain better property values. Your code may ' also subscribe to the item in order to assure that it remains active. ' ' Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html . ' OPC client and subscriber examples in VB.NET on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-VBNET . ' Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own ' a commercial license in order to use Online Forums, and we reply to every post. Imports OpcLabs.EasyOpc.DataAccess Imports OpcLabs.EasyOpc.OperationModel Namespace DataAccess.Xml Partial Friend Class GetPropertyValue Public Shared Sub Main1Xml() Dim client = New EasyDAClient() Dim value As Object Try value = client.GetPropertyValue("http://opcxml.demo-this.com/XmlDaSampleServer/Service.asmx", "Dynamic/Analog Types/Int", DAPropertyDescriptor.Timestamp) Catch opcException As OpcException Console.WriteLine("*** Failure: {0}", opcException.GetBaseException().Message) Exit Sub End Try Console.WriteLine(value) End Sub End Class End Namespace
# This example shows how to get a value of a single OPC XML-DA property. # # Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html . # OPC client and subscriber examples in Python on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-Python . # Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own # a commercial license in order to use Online Forums, and we reply to every post. # The QuickOPC package is needed. Install it using "pip install opclabs_quickopc". import opclabs_quickopc # Import .NET namespaces. from OpcLabs.EasyOpc import * from OpcLabs.EasyOpc.DataAccess import * # Instantiate the client object. client = EasyDAClient() # Perform the operation try: value = IEasyDAClientExtension.GetPropertyValue(client, ServerDescriptor('http://opcxml.demo-this.com/XmlDaSampleServer/Service.asmx'), DANodeDescriptor('Dynamic/Analog Types/Int'), DAPropertyDescriptor(DAPropertyId(DAPropertyDescriptor.Timestamp))) except OpcException as opcException: print('*** Failure: ' + opcException.GetBaseException().Message, sep='') exit() # Display results print('value: ', value, sep='')
Copyright © 2004-2024 CODE Consulting and Development, s.r.o., Plzen. All rights reserved. Web page: www.opclabs.com
Documentation Home, Send Feedback. Resources: Knowledge Base, Product Downloads. Technical support: Online Forums, FAQ.Missing some example? Ask us for it on our Online Forums! You do not have to own a commercial license in order to use Online Forums, and we reply to every post.